![]() |
StdTxMeas |
||||
Header: | QuickdrawText.h | Carbon status: | Supported | |
Measures the width of scaled or unscaled text.
SInt16 StdTxMeas ( SInt16 byteCount, const void *textAddr, Point *numer, Point *denom, FontInfo *info );
The number of bytes to be counted.
A pointer to the beginning of the text in memory.
Pointer to a point giving the numerator for the horizontal and vertical scaling factors. For this function, numer and denom are reference parameters. On output, these parameters contain additional scaling to be applied to the text.
Both numer and denom are point values: numer specifies the numerator for the horizontal and vertical scaling factors, and denom specifies the denominator for the horizontal and vertical scaling factors. Together, these values specify the scaling factors for the text: numer.v over denom.v gives the vertical scaling (height), and numer.h over denom.h gives the horizontal scaling factors (width). You need to specify values for numer and denom even if you are not scaling the text. For unscaled text, you can specify scaling factors of 1, 1.
Pointer to a point giving the denominator for the horizontal and vertical scaling factors.
Pointer to a font information structure that describes the current font.
The width of the text stored in memory, beginning with the first character at textAddr and continuing for byteCount bytes.
The StdTxMeas function is a QuickDraw bottleneck function that the QuickDraw text-measuring functions use extensively. The StdTxMeas function returns the width of the text stored in memory beginning with the first character at textAddr and continuing for byteCount bytes. You can call the StdTxMeas function directly, for example, to measure text that you want to explicitly scale, but not justify. You can also use StdTxMeas to get the font metrics for scaled text in order to determine the line height, instead of using GetFontInfo, which doesn’t support scaling.
The high-level QuickDraw text functions provide most of the functionality needed to measure and draw text. However, if you need to call StdTxMeas directly, you must first check the graphics port grafProcs field to determine whether the bottleneck functions have been customized, and if so, you must call the customized function instead of the standard one. The bottleneck functions are always customized for printing.
If the grafProcs field contains NULL, the standard bottleneck functions have not been customized. If the grafProcs field contains a pointer, the standard bottleneck functions have been replaced by customized ones. This pointer (of type QDProcPtr) points to a QDProc structure, which contains fields that point to the bottleneck function to be used for a specific drawing function. If the standard bottleneck function has been customized, your application needs to use the customized function indicated by the QDProc structure field.
On input, you need to specify values for numer and denom, even if you are not scaling the text. You can specify 1,1 scaling factors, in this case, so that no scaling is applied. On return, numer and denom contain the additional scaling to be applied to the text.
The StdTxtMeas function returns output scaling factors that you need to apply to the text to get the right measurement if the Font Manager was not able to fully satisfy the scaling request. You can use the Toolbox Utilities’ FixRound and FixRatio functions to help with this process.
The StdTxMeas function gives the correct results for all script systems. The byteCount parameter is the number of bytes of the text to be drawn, not characters. When specifying this value, consider that 2-byte script systems also include characters consisting of only one byte.
Supported in Carbon. Available in Carbon 1.0.2 and later when running Mac OS 8.1 or later.
© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)